package com.sxz.sbs.module.client.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.client.bean.ClientStallListBean;
import com.sxz.sbs.module.client.view.StallListView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;
import java.util.List;

/**
 * 获取客户车位列表
 * @author hp
 */
public class StallListPresenter extends RxPresenter<StallListView>{
    /**
     * @param map
     */
    public void getStallList (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getStallList(map)
                .compose(RxUtil.<List<ClientStallListBean>>handleResult())
                .subscribeWith(new RxSubscriber<List<ClientStallListBean>>(mView){
                    @Override
                    public void onNext(List<ClientStallListBean> data) {
                       mView.onStallListSuccess(data);
                    }
                })
        );
    }
    public void deleteStallList (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().deleteStallList(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onDeleteStallSuccess();
                    }
                })
        );
    }
}
